$(document).ready(function() {
    var slidedForm = 1;
    var lastClicked;
    var time = 250;
    // показать форму если в УРЛ есть #comment-form
    var loc = window.location.toString();
    var x = loc.search("#");
    if (x > 0) {
        if(loc.substring(x,loc.length) == '#comment-form') {
            $('#comment-form').css({'display':'block'});
            console.log(loc);
        }
    }
    //////////////////
    function slide(target) {
        
        if(slidedForm) {
           
            $('.hiddenForm').show();
        } else {
           
            $('.hiddenForm').slideUp(time);
        }
        slidedForm = slidedForm ? 0 : 1;
    }
    $('.close_form').click(function(){
        
        slidedForm=1;
        $('.hiddenForm').hide();
    }); 

    $('.comment_otv').click(function() {
        var comId = $(this).parent().children('.comId').val();
      
        $('.comParentId').val(comId);
        var target = this;
        if(lastClicked != comId) {
            if(!slidedForm) {
                $('.form').each(function(){$(this).slideUp(time);});
                $('.hiddenForm').slideUp(time, function() { slide(target); });
                slidedForm = 1;
            } else slide(target);
            lastClicked = comId;
        } else slide(this);  
    });
});